package com.jd.sunny.java.httpclient;


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;

public class JavaPostTest {

    public String post() throws Exception {
        URL url = new URL("http://localhost:8080/ccmis/creditcardnocard/traderequst/getInformation");
        URLConnection conn = url.openConnection();
        conn.setDoOutput(true);

        OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());

        writer.write("doGet");
        writer.flush();
        writer.close();

        InputStreamReader reder = new InputStreamReader(conn.getInputStream(), "utf-8");

        BufferedReader breader = new BufferedReader(reder);

        //BufferedWriter w = new BufferedWriter(new FileWriter("d:/1.txt"));  

        String content = "";
        String result = "";
        while ((content = breader.readLine()) != null) {
            result += content + "\n";
        }
//        w.write(result);  
//        w.flush();  
//        w.close();  
        return result;

    }

    public static void main(String[] args) throws Exception {
        JavaPostTest post = new JavaPostTest();
        String aa = post.post();
        String bb = new String(aa.getBytes("utf-8"));
        System.out.println(bb);
    }
}  